|
2 | 2 |
|
3 | 3 | This example shows how to setup OpenTelemetry OTLP exporter for logs, metrics
|
4 | 4 | and traces to exports them to the [OpenTelemetry
|
5 |
| -Collector](https://github.com/open-telemetry/opentelemetry-collector) via OTLP over HTTP. |
6 |
| -The Collector then sends the data to the appropriate backend, in this case, |
7 |
| -the logging Exporter, which displays data to console. |
| 5 | +Collector](https://github.com/open-telemetry/opentelemetry-collector) via OTLP |
| 6 | +over HTTP/protobuf. The Collector then sends the data to the appropriate |
| 7 | +backend, in this case, the logging Exporter, which displays data to console. |
8 | 8 |
|
9 | 9 | ## Usage
|
10 | 10 |
|
@@ -47,208 +47,130 @@ You should be able to see something similar below with different time and ID in
|
47 | 47 | ### Span
|
48 | 48 |
|
49 | 49 | ```text
|
50 |
| -2023-09-08T21:50:35.884Z info ResourceSpans #0 |
| 50 | +... |
| 51 | +2024-05-14T02:15:56.827Z info ResourceSpans #0 |
51 | 52 | Resource SchemaURL:
|
52 | 53 | Resource attributes:
|
53 |
| - -> service.name: Str(basic-otlp-tracing-example) |
| 54 | + -> service.name: Str(basic-otlp-example) |
54 | 55 | ScopeSpans #0
|
55 | 56 | ScopeSpans SchemaURL:
|
56 |
| -InstrumentationScope ex.com/basic |
| 57 | +InstrumentationScope basic |
| 58 | +InstrumentationScope attributes: |
| 59 | + -> scope-key: Str(scope-value) |
57 | 60 | Span #0
|
58 |
| - Trace ID : f8e7ea4dcab43689cea14f708309d682 |
59 |
| - Parent ID : 8b560e2e7238eab5 |
60 |
| - ID : 9e36b48dc07b32fe |
| 61 | + Trace ID : 4467894e2d8d0c4165df1218160bc260 |
| 62 | + Parent ID : 589ea953b6ec03a9 |
| 63 | + ID : b2aa3c3a9c21e0d0 |
61 | 64 | Name : Sub operation...
|
62 | 65 | Kind : Internal
|
63 |
| - Start time : 2023-09-08 21:50:35.872800345 +0000 UTC |
64 |
| - End time : 2023-09-08 21:50:35.87282574 +0000 UTC |
| 66 | + Start time : 2024-05-14 02:15:56.824239163 +0000 UTC |
| 67 | + End time : 2024-05-14 02:15:56.824244315 +0000 UTC |
65 | 68 | Status code : Unset
|
66 | 69 | Status message :
|
67 | 70 | Attributes:
|
68 |
| - -> lemons: Str(five) |
| 71 | + -> another.key: Str(yes) |
69 | 72 | Events:
|
70 | 73 | SpanEvent #0
|
71 | 74 | -> Name: Sub span event
|
72 |
| - -> Timestamp: 2023-09-08 21:50:35.872808684 +0000 UTC |
| 75 | + -> Timestamp: 2024-05-14 02:15:56.82424188 +0000 UTC |
73 | 76 | -> DroppedAttributesCount: 0
|
74 | 77 | ResourceSpans #1
|
75 | 78 | Resource SchemaURL:
|
76 | 79 | Resource attributes:
|
77 |
| - -> service.name: Str(basic-otlp-tracing-example) |
| 80 | + -> service.name: Str(basic-otlp-example) |
78 | 81 | ScopeSpans #0
|
79 | 82 | ScopeSpans SchemaURL:
|
80 |
| -InstrumentationScope ex.com/basic |
| 83 | +InstrumentationScope basic |
| 84 | +InstrumentationScope attributes: |
| 85 | + -> scope-key: Str(scope-value) |
81 | 86 | Span #0
|
82 |
| - Trace ID : f8e7ea4dcab43689cea14f708309d682 |
| 87 | + Trace ID : 4467894e2d8d0c4165df1218160bc260 |
83 | 88 | Parent ID :
|
84 |
| - ID : 8b560e2e7238eab5 |
85 |
| - Name : operation |
| 89 | + ID : 589ea953b6ec03a9 |
| 90 | + Name : Main operation |
86 | 91 | Kind : Internal
|
87 |
| - Start time : 2023-09-08 21:50:35.872735497 +0000 UTC |
88 |
| - End time : 2023-09-08 21:50:35.872832026 +0000 UTC |
| 92 | + Start time : 2024-05-14 02:15:56.824194899 +0000 UTC |
| 93 | + End time : 2024-05-14 02:15:56.824251136 +0000 UTC |
89 | 94 | Status code : Unset
|
90 | 95 | Status message :
|
91 | 96 | Attributes:
|
92 |
| - -> ex.com/another: Str(yes) |
| 97 | + -> another.key: Str(yes) |
93 | 98 | Events:
|
94 | 99 | SpanEvent #0
|
95 | 100 | -> Name: Nice operation!
|
96 |
| - -> Timestamp: 2023-09-08 21:50:35.872750123 +0000 UTC |
| 101 | + -> Timestamp: 2024-05-14 02:15:56.824201397 +0000 UTC |
97 | 102 | -> DroppedAttributesCount: 0
|
98 | 103 | -> Attributes::
|
99 | 104 | -> bogons: Int(100)
|
100 | 105 | {"kind": "exporter", "data_type": "traces", "name": "logging"}
|
| 106 | +... |
101 | 107 | ```
|
102 | 108 |
|
103 | 109 | ### Metric
|
104 | 110 |
|
105 | 111 | ```text
|
106 |
| -2023-09-08T19:14:12.522Z info ResourceMetrics #0 |
| 112 | +... |
| 113 | +2024-05-14T02:15:56.827Z info ResourceMetrics #0 |
107 | 114 | Resource SchemaURL:
|
108 | 115 | Resource attributes:
|
109 |
| - -> service.name: Str(basic-otlp-metrics-example) |
| 116 | + -> service.name: Str(basic-otlp-example) |
110 | 117 | ScopeMetrics #0
|
111 |
| -ScopeMetrics SchemaURL: |
112 |
| -InstrumentationScope ex.com/basic |
| 118 | +ScopeMetrics SchemaURL: schema_url |
| 119 | +InstrumentationScope basic v1.0 |
| 120 | +InstrumentationScope attributes: |
| 121 | + -> scope-key: Str(scope-value) |
113 | 122 | Metric #0
|
114 | 123 | Descriptor:
|
115 |
| - -> Name: ex.com.one |
116 |
| - -> Description: A gauge set to 1.0 |
117 |
| - -> Unit: |
118 |
| - -> DataType: Gauge |
119 |
| -NumberDataPoints #0 |
120 |
| -Data point attributes: |
121 |
| - -> A: Str(1) |
122 |
| - -> B: Str(2) |
123 |
| - -> C: Str(3) |
124 |
| - -> lemons: Int(10) |
125 |
| -StartTimestamp: 1970-01-01 00:00:00 +0000 UTC |
126 |
| -Timestamp: 2023-09-08 19:14:12.468030127 +0000 UTC |
127 |
| -Value: 1.000000 |
128 |
| -Metric #1 |
129 |
| -Descriptor: |
130 |
| - -> Name: ex.com.two |
131 |
| - -> Description: |
132 |
| - -> Unit: |
133 |
| - -> DataType: Histogram |
| 124 | + -> Name: test_counter |
| 125 | + -> Description: a simple counter for demo purposes. |
| 126 | + -> Unit: my_unit |
| 127 | + -> DataType: Sum |
| 128 | + -> IsMonotonic: true |
134 | 129 | -> AggregationTemporality: Cumulative
|
135 |
| -HistogramDataPoints #0 |
| 130 | +NumberDataPoints #0 |
136 | 131 | Data point attributes:
|
137 |
| - -> A: Str(1) |
138 |
| - -> B: Str(2) |
139 |
| - -> C: Str(3) |
140 |
| - -> lemons: Int(10) |
141 |
| -StartTimestamp: 2023-09-08 19:14:12.466896812 +0000 UTC |
142 |
| -Timestamp: 2023-09-08 19:14:12.468052807 +0000 UTC |
143 |
| -Count: 1 |
144 |
| -Sum: 5.500000 |
145 |
| -Min: 5.500000 |
146 |
| -Max: 5.500000 |
147 |
| -ExplicitBounds #0: 0.000000 |
148 |
| -ExplicitBounds #1: 5.000000 |
149 |
| -ExplicitBounds #2: 10.000000 |
150 |
| -ExplicitBounds #3: 25.000000 |
151 |
| -ExplicitBounds #4: 50.000000 |
152 |
| -ExplicitBounds #5: 75.000000 |
153 |
| -ExplicitBounds #6: 100.000000 |
154 |
| -ExplicitBounds #7: 250.000000 |
155 |
| -ExplicitBounds #8: 500.000000 |
156 |
| -ExplicitBounds #9: 750.000000 |
157 |
| -ExplicitBounds #10: 1000.000000 |
158 |
| -ExplicitBounds #11: 2500.000000 |
159 |
| -ExplicitBounds #12: 5000.000000 |
160 |
| -ExplicitBounds #13: 7500.000000 |
161 |
| -ExplicitBounds #14: 10000.000000 |
162 |
| -Buckets #0, Count: 0 |
163 |
| -Buckets #1, Count: 0 |
164 |
| -Buckets #2, Count: 1 |
165 |
| -Buckets #3, Count: 0 |
166 |
| -Buckets #4, Count: 0 |
167 |
| -Buckets #5, Count: 0 |
168 |
| -Buckets #6, Count: 0 |
169 |
| -Buckets #7, Count: 0 |
170 |
| -Buckets #8, Count: 0 |
171 |
| -Buckets #9, Count: 0 |
172 |
| -Buckets #10, Count: 0 |
173 |
| -Buckets #11, Count: 0 |
174 |
| -Buckets #12, Count: 0 |
175 |
| -Buckets #13, Count: 0 |
176 |
| -Buckets #14, Count: 0 |
177 |
| -Buckets #15, Count: 0 |
178 |
| -HistogramDataPoints #1 |
179 |
| -StartTimestamp: 2023-09-08 19:14:12.466896812 +0000 UTC |
180 |
| -Timestamp: 2023-09-08 19:14:12.468052807 +0000 UTC |
181 |
| -Count: 1 |
182 |
| -Sum: 1.300000 |
183 |
| -Min: 1.300000 |
184 |
| -Max: 1.300000 |
185 |
| -ExplicitBounds #0: 0.000000 |
186 |
| -ExplicitBounds #1: 5.000000 |
187 |
| -ExplicitBounds #2: 10.000000 |
188 |
| -ExplicitBounds #3: 25.000000 |
189 |
| -ExplicitBounds #4: 50.000000 |
190 |
| -ExplicitBounds #5: 75.000000 |
191 |
| -ExplicitBounds #6: 100.000000 |
192 |
| -ExplicitBounds #7: 250.000000 |
193 |
| -ExplicitBounds #8: 500.000000 |
194 |
| -ExplicitBounds #9: 750.000000 |
195 |
| -ExplicitBounds #10: 1000.000000 |
196 |
| -ExplicitBounds #11: 2500.000000 |
197 |
| -ExplicitBounds #12: 5000.000000 |
198 |
| -ExplicitBounds #13: 7500.000000 |
199 |
| -ExplicitBounds #14: 10000.000000 |
200 |
| -Buckets #0, Count: 0 |
201 |
| -Buckets #1, Count: 1 |
202 |
| -Buckets #2, Count: 0 |
203 |
| -Buckets #3, Count: 0 |
204 |
| -Buckets #4, Count: 0 |
205 |
| -Buckets #5, Count: 0 |
206 |
| -Buckets #6, Count: 0 |
207 |
| -Buckets #7, Count: 0 |
208 |
| -Buckets #8, Count: 0 |
209 |
| -Buckets #9, Count: 0 |
210 |
| -Buckets #10, Count: 0 |
211 |
| -Buckets #11, Count: 0 |
212 |
| -Buckets #12, Count: 0 |
213 |
| -Buckets #13, Count: 0 |
214 |
| -Buckets #14, Count: 0 |
215 |
| -Buckets #15, Count: 0 |
216 |
| - {"kind": "exporter", "data_type": "metrics", "name": "logging"} |
| 132 | + -> test_key: Str(test_value) |
| 133 | +StartTimestamp: 2024-05-14 02:15:56.824127393 +0000 UTC |
| 134 | +Timestamp: 2024-05-14 02:15:56.825354918 +0000 UTC |
| 135 | +Value: 11 |
| 136 | +... |
217 | 137 | ```
|
218 | 138 |
|
219 | 139 | ### Logs
|
220 | 140 |
|
221 | 141 | ```text
|
222 |
| -2023-09-08T21:50:35.884Z info ResourceLog #0 |
| 142 | +... |
| 143 | +2024-05-14T02:15:56.828Z info ResourceLog #0 |
223 | 144 | Resource SchemaURL:
|
224 | 145 | Resource attributes:
|
225 |
| - -> service.name: Str(basic-otlp-logging-example) |
| 146 | + -> service.name: Str(basic-otlp-example) |
226 | 147 | ScopeLogs #0
|
227 | 148 | ScopeLogs SchemaURL:
|
228 |
| -InstrumentationScope opentelemetry-log-appender 0.1.0 |
| 149 | +InstrumentationScope opentelemetry-log-appender 0.3.0 |
229 | 150 | LogRecord #0
|
230 |
| -ObservedTimestamp: 2023-09-08 21:50:35.872759168 +0000 UTC |
| 151 | +ObservedTimestamp: 2024-05-14 02:15:56.824218088 +0000 UTC |
231 | 152 | Timestamp: 1970-01-01 00:00:00 +0000 UTC
|
232 | 153 | SeverityText: INFO
|
233 | 154 | SeverityNumber: Info(9)
|
234 | 155 | Body: Str(hello from banana. My price is 2.99. I am also inside a Span!)
|
235 |
| -Trace ID: f8e7ea4dcab43689cea14f708309d682 |
236 |
| -Span ID: 8b560e2e7238eab5 |
| 156 | +Trace ID: 4467894e2d8d0c4165df1218160bc260 |
| 157 | +Span ID: 589ea953b6ec03a9 |
237 | 158 | Flags: 1
|
238 | 159 | ResourceLog #1
|
239 | 160 | Resource SchemaURL:
|
240 | 161 | Resource attributes:
|
241 |
| - -> service.name: Str(basic-otlp-logging-example) |
| 162 | + -> service.name: Str(basic-otlp-example) |
242 | 163 | ScopeLogs #0
|
243 | 164 | ScopeLogs SchemaURL:
|
244 |
| -InstrumentationScope opentelemetry-log-appender 0.1.0 |
| 165 | +InstrumentationScope opentelemetry-log-appender 0.3.0 |
245 | 166 | LogRecord #0
|
246 |
| -ObservedTimestamp: 2023-09-08 21:50:35.872833713 +0000 UTC |
| 167 | +ObservedTimestamp: 2024-05-14 02:15:56.824254268 +0000 UTC |
247 | 168 | Timestamp: 1970-01-01 00:00:00 +0000 UTC
|
248 | 169 | SeverityText: INFO
|
249 | 170 | SeverityNumber: Info(9)
|
250 | 171 | Body: Str(hello from apple. My price is 1.99)
|
251 | 172 | Trace ID:
|
252 | 173 | Span ID:
|
253 | 174 | Flags: 0
|
| 175 | +... |
254 | 176 | ```
|
0 commit comments