Skip to content

Commit 25f7ce3

Browse files
committed
WIP
1 parent 20cba04 commit 25f7ce3

File tree

3 files changed

+235
-2
lines changed

3 files changed

+235
-2
lines changed
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
# kitchen-sink.yaml demonstrates all configurable surface area, including explanatory comments.
2+
#
3+
# It DOES NOT represent expected real world file configuration, as it makes strange file configuration
4+
# choices in an effort to exercise the full surface area.
5+
#
6+
# Configuration values are set to their defaults when default values are defined.
7+
8+
# The file format version
9+
file_format: "0.1"
10+
11+
# Configure if the SDK is disabled or not. This is not required to be provided
12+
# to ensure the SDK isn't disabled, the default value when this is not provided
13+
# is for the SDK to be enabled.
14+
#
15+
# Environment variable: OTEL_SDK_DISABLED
16+
disabled: false
17+
18+
# Configure general attribute limits. See also tracer_provider.limits, logger_provider.limits.
19+
attribute_limits:
20+
# Configure max attribute value size.
21+
#
22+
# Environment variable: OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT
23+
attribute_value_length_limit: 4096
24+
# Configure max attribute count.
25+
#
26+
# Environment variable: OTEL_ATTRIBUTE_COUNT_LIMIT
27+
attribute_count_limit: 128
28+
29+
# Configure text map context propagators.
30+
#
31+
# Environment variable: OTEL_PROPAGATORS
32+
propagator:
33+
composite: [tracecontext, baggage, b3, b3multi, jaeger, xray, ottrace]
34+
35+
# Configure tracer provider.
36+
tracer_provider:
37+
# Configure span processors.
38+
processors:
39+
# Configure a batch span processor.
40+
- batch:
41+
# Configure delay interval (in milliseconds) between two consecutive exports.
42+
#
43+
# Environment variable: OTEL_BSP_SCHEDULE_DELAY
44+
schedule_delay: 5000
45+
# Configure maximum allowed time (in milliseconds) to export data.
46+
#
47+
# Environment variable: OTEL_BSP_EXPORT_TIMEOUT
48+
export_timeout: 30000
49+
# Configure maximum queue size.
50+
#
51+
# Environment variable: OTEL_BSP_MAX_QUEUE_SIZE
52+
max_queue_size: 2048
53+
# Configure maximum batch size.
54+
#
55+
# Environment variable: OTEL_BSP_MAX_EXPORT_BATCH_SIZE
56+
max_export_batch_size: 512
57+
# Configure exporter.
58+
#
59+
# Environment variable: OTEL_TRACES_EXPORTER
60+
exporter:
61+
# Configure exporter to be OTLP.
62+
otlp:
63+
# Configure protocol.
64+
#
65+
# Environment variable: OTEL_EXPORTER_OTLP_PROTOCOL, OTEL_EXPORTER_OTLP_TRACES_PROTOCOL
66+
protocol: http/protobuf
67+
# Configure endpoint.
68+
#
69+
# Environment variable: OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
70+
endpoint: http://localhost:4318
71+
# Configure certificate.
72+
#
73+
# Environment variable: OTEL_EXPORTER_OTLP_CERTIFICATE, OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE
74+
certificate: /app/cert.pem
75+
# Configure mTLS private client key.
76+
#
77+
# Environment variable: OTEL_EXPORTER_OTLP_CLIENT_KEY, OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY
78+
client_key: /app/cert.pem
79+
# Configure mTLS client certificate.
80+
#
81+
# Environment variable: OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE, OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATE
82+
client_certificate: /app/cert.pem
83+
# Configure headers.
84+
#
85+
# Environment variable: OTEL_EXPORTER_OTLP_HEADERS, OTEL_EXPORTER_OTLP_TRACES_HEADERS
86+
headers:
87+
api-key: !!str 1234
88+
# Configure compression.
89+
#
90+
# Environment variable: OTEL_EXPORTER_OTLP_COMPRESSION, OTEL_EXPORTER_OTLP_TRACES_COMPRESSION
91+
compression: gzip
92+
# Configure max time (in milliseconds) to wait for each export.
93+
#
94+
# Environment variable: OTEL_EXPORTER_OTLP_TIMEOUT, OTEL_EXPORTER_OTLP_TRACES_TIMEOUT
95+
timeout: 10000
96+
# Configure a batch span processor.
97+
- batch:
98+
# Configure exporter.
99+
#
100+
# Environment variable: OTEL_TRACES_EXPORTER
101+
schedule_delay: 5000
102+
exporter:
103+
# Configure exporter to be zipkin.
104+
zipkin:
105+
# Configure endpoint.
106+
#
107+
# Environment variable: OTEL_EXPORTER_ZIPKIN_ENDPOINT
108+
endpoint: http://localhost:9411/api/v2/spans
109+
# Configure max time (in milliseconds) to wait for each export.
110+
#
111+
# Environment variable: OTEL_EXPORTER_ZIPKIN_TIMEOUT
112+
timeout: 10000
113+
# Configure a simple span processor.
114+
- simple:
115+
# Configure exporter.
116+
exporter:
117+
# Configure exporter to be console.
118+
console: {}
119+
# Configure span limits. See also attribute_limits.
120+
limits:
121+
# Configure max span attribute value size. Overrides attribute_limits.attribute_value_length_limit.
122+
#
123+
# Environment variable: OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT
124+
attribute_value_length_limit: 4096
125+
# Configure max span attribute count. Overrides attribute_limits.attribute_count_limit.
126+
#
127+
# Environment variable: OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT
128+
attribute_count_limit: 128
129+
# Configure max span event count.
130+
#
131+
# Environment variable: OTEL_SPAN_EVENT_COUNT_LIMIT
132+
event_count_limit: 128
133+
# Configure max span link count.
134+
#
135+
# Environment variable: OTEL_SPAN_LINK_COUNT_LIMIT
136+
link_count_limit: 128
137+
# Configure max attributes per span event.
138+
#
139+
# Environment variable: OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT
140+
event_attribute_count_limit: 128
141+
# Configure max attributes per span link.
142+
#
143+
# Environment variable: OTEL_LINK_ATTRIBUTE_COUNT_LIMIT
144+
link_attribute_count_limit: 128
145+
# Configure the sampler.
146+
sampler:
147+
# Configure sampler to be parent_based. Known values include: always_off, always_on, jaeger_remote, parent_based, trace_id_ratio_based.
148+
#
149+
# Environment variable: OTEL_TRACES_SAMPLER=parentbased_*
150+
parent_based:
151+
# Configure root sampler.
152+
#
153+
# Environment variable: OTEL_TRACES_SAMPLER=parentbased_traceidratio
154+
root:
155+
# Configure sampler to be trace_id_ratio_based.
156+
trace_id_ratio_based:
157+
# Configure trace_id_ratio.
158+
#
159+
# Environment variable: OTEL_TRACES_SAMPLER_ARG=traceidratio=0.0001
160+
ratio: 0.0001
161+
# Configure remote_parent_sampled sampler.
162+
remote_parent_sampled:
163+
# Configure sampler to be always_on.
164+
always_on: {}
165+
# Configure remote_parent_not_sampled sampler.
166+
remote_parent_not_sampled:
167+
# Configure sampler to be always_off.
168+
always_off: {}
169+
# Configure local_parent_sampled sampler.
170+
local_parent_sampled:
171+
# Configure sampler to be always_on.
172+
always_on: {}
173+
# Configure local_parent_not_sampled sampler.
174+
local_parent_not_sampled:
175+
parent_based:
176+
remote_parent_not_sampled:
177+
trace_id_ratio_based:
178+
ratio: 0.0001
179+
180+
# Configure resource for all signals.
181+
resource:
182+
# Configure resource attributes.
183+
#
184+
# Environment variable: OTEL_RESOURCE_ATTRIBUTES
185+
attributes:
186+
# Configure `service.name` resource attribute
187+
#
188+
# Environment variable: OTEL_SERVICE_NAME
189+
service.name: !!str "unknown_service"
190+
# Configure the resource schema URL.
191+
schema_url: https://opentelemetry.io/schemas/1.16.0

_file_configuration/tests/test_file_configuration.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,42 @@ def test_dry_run():
192192
)
193193

194194

195+
def test_dry_run_multiple_span_processors():
196+
197+
file_configuration = load_file_configuration(
198+
data_path.joinpath("file_configuration").joinpath(
199+
"file_configuration_3.yaml"
200+
)
201+
)
202+
203+
schema_path = data_path.joinpath("schema").joinpath(
204+
"opentelemetry_file_configuration.json"
205+
)
206+
207+
resolved_schema = resolve_schema(schema_path)
208+
209+
try:
210+
validate_file_configuration(resolved_schema, file_configuration)
211+
except Exception as error:
212+
fail(f"Unexpected exception raised: {error}")
213+
214+
processed_schema = process_schema(resolved_schema)
215+
216+
set_resource(
217+
create_object(file_configuration, processed_schema, "resource")
218+
)
219+
220+
print()
221+
print(
222+
create_object(
223+
file_configuration,
224+
processed_schema,
225+
"tracer_provider",
226+
dry_run=True,
227+
)
228+
)
229+
230+
195231
def test_plugin():
196232

197233
file_configuration = load_file_configuration(

opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,7 @@ def __init__(
12121212
self._resource = resource
12131213
if not sampler:
12141214
sampler = sampling._get_from_env_or_default()
1215+
self._shutdown_on_exit = self._shutdown_on_exit
12151216
self.sampler = sampler
12161217
self._span_limits = span_limits or SpanLimits()
12171218
disabled = environ.get(OTEL_SDK_DISABLED, "")
@@ -1222,10 +1223,15 @@ def __init__(
12221223
self._atexit_handler = atexit.register(self.shutdown)
12231224

12241225
def __repr__(self) -> str:
1226+
from ipdb import set_trace
1227+
set_trace()
12251228
return (
12261229
f"{self.__class__.__name__}("
1227-
f"{repr(self.sampler)},"
1228-
f"{repr(self._resource)},"
1230+
f"sampler={repr(self.sampler)},"
1231+
f"resource={repr(self._resource)},"
1232+
f"shutdown_on_exit={repr(self._shutdown_on_exit)},"
1233+
f"active_span_processor={repr(self._active_span_processor)},"
1234+
f"id_generator={repr(self._active_span_processor)},"
12291235
")"
12301236
)
12311237

0 commit comments

Comments
 (0)