Conversation
|
TODO: add documentation before merging |
|
I can see how having just a code fragment (snippet) is useful for the documentation. The downside is that this fragment can no longer be used as a stand alone test. Could the snippet file format be extended for example like this: file_format: "1.0-rc2"
meter_provider:
readers:
periodic:
exporter:
otlp_http:
# === SNIPPET START HERE ===
endpoint: http://localhost:4318/v1/metrics
default_histogram_aggregation: base2_exponential_bucket_histogram
# === SNIPPET ENDS HERE ===Assuming the tooling can extract the snippet, this will allow:
Each SDK implementation will gain a lot if running tests straight from the configuration repository, to make sure the SDK code does not diverge from the schema over time. |
@marcalff for java, I was imagining building a test harness which:
Yes that's possible too. Its more verbose of course, which is the downside. But the upside is that when rendering the snippet in the docs, we could optionally render the entire document with the embedded snippet, which would probably help make it more obvious where the type is actually used. |
|
@marcalff I've come around to the approach you've suggested, pushed a commit reflecting it, and updated the PR description. A typical snippet now looks like: File contents at file_format: "1.0-rc.2"
tracer_provider:
processors:
- simple:
exporter:
console:
# SNIPPET_START
sampler:
parent_based:
root:
trace_id_ratio_based:
ratio: 0.0001
remote_parent_sampled:
always_on:
remote_parent_not_sampled:
probability/development:
ratio: 0.01
local_parent_sampled:
always_on:
local_parent_not_sampled:
always_off:
Pretty cool, I think. Should be very useful for users and maintainers alike. |
marcalff
left a comment
There was a problem hiding this comment.
LGTM, this will be very useful.
First take on #393.
Details:
/snippetsdirectly with files named<JsonSchemaType>_<snake_case_snippet_description>.yamlOpenTelemetryConfigurationtype, but is meant to emphasize a particular snippet of a specific type, indicated by the<JsonSchemaType>in the file naming conventionmake validate-snippetsvalidates each snippet file againstOpenTelemetryConfiguration, and the snippet being emphasized (as indicated by# SNIPPET_START) against its corresponding JSON schema typemake generate-markdowntask outputs snippets inschema-docs.md. For example, I've added a snippet demonstrating how to use a view to change the default histogram bucket boundaries for a specific instrument via a view. See screenshot below, or generated markdown here:If we like this direction, we can open followup PRs which chip away at
kitchen-sink.yaml, and delete it.