Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default exporting to http/protobuf #961

Merged
merged 6 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/advanced-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ This distribution supports all the configuration options supported by the compon
| --------------------------------------------------------------- | ----------------------- | ------- | ---
| `OTEL_ATTRIBUTE_COUNT_LIMIT` | | Stable | Maximum allowed span attribute count
| `OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT` | `12000`\* | Stable | Maximum allowed attribute value size
| `OTEL_EXPORTER_OTLP_ENDPOINT`<br>`endpoint` | `http://localhost:4317` | Stable | The OTLP endpoint to export to.
| `OTEL_EXPORTER_OTLP_ENDPOINT`<br>`endpoint` | `http://localhost:4318` | Stable | The OTLP endpoint to export to.
| `OTEL_LOG_LEVEL` | | Stable | Log level to use in diagnostics logging. **Does not set the logger.**
| `OTEL_PROPAGATORS`<br>`tracing.propagators` | `tracecontext,baggage` | Stable | Comma-delimited list of propagators to use. Valid keys: `baggage`, `tracecontext`, `b3multi`, `b3`.
| `OTEL_RESOURCE_ATTRIBUTES` | | Stable | Comma-separated list of resource attributes added to every reported span. <details><summary>Example</summary>`key1=val1,key2=val2`</details>
Expand Down Expand Up @@ -97,10 +97,10 @@ The following config options can be set by passing them as tracing arguments to
| Environment variable<br>``start()`` argument | Default value | Support | Notes
| --------------------------------------------------------------- | ----------------------- | ------- | ---
| `OTEL_SERVICE_NAME`<br>`serviceName` | `unnamed-node-service` | Stable | The service name of this Node service.
| `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT`<br>`endpoint` | `http://localhost:4317` | Stable | The OTLP endpoint to export to.
| `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT`<br>`endpoint` | `http://localhost:4318` | Stable | The OTLP endpoint to export to.
| `OTEL_METRIC_EXPORT_INTERVAL`<br>`metrics.exportIntervalMillis` | `30000` | Stable | The interval, in milliseconds, of metrics collection and exporting.
| `OTEL_METRICS_EXPORTER`<br>`metrics.metricReaderFactory` | `otlp` | Stable | Chooses the metric exporters. Comma-delimited list of exporters. Currently supported values: `otlp`, `console`, `none`.
| `OTEL_EXPORTER_OTLP_METRICS_PROTOCOL`<br>`metrics.metricReaderFactory` | `grpc` | Stable | Chooses the metric exporter protocol. Currently supported values: `grpc`, `http/protobuf`.
| `OTEL_EXPORTER_OTLP_METRICS_PROTOCOL`<br>`metrics.metricReaderFactory` | `http/protobuf` | Stable | Chooses the metric exporter protocol. Currently supported values: `grpc`, `http/protobuf`.
| `OTEL_RESOURCE_ATTRIBUTES` | | Stable | The resource attributes to metric data. <details><summary>Environment variable example</summary>`key1=val1,key2=val2`</details>
| `SPLUNK_METRICS_ENABLED`<br>n/a (enabled by calling `start`) | `false` | Experimental | Sets up the metrics pipeline (global meter provider, exporters).
| n/a<br>`metrics.resourceFactory` | | Experimental | Callback which allows to filter the default resource or provide a custom one. The function takes one argument of type `Resource` which is the resource pre-filled by the SDK containing the `service.name`, environment, host and process attributes. |
Expand All @@ -114,7 +114,7 @@ The following config options can be set by passing them as tracing arguments to
| --------------------------------------------------------------- | ----------------------- | ------- | ---
| `SPLUNK_PROFILER_ENABLED` | `false` | Experimental | Enable continuous profiling.
| `SPLUNK_PROFILER_MEMORY_ENABLED`<br>`profiling.memoryProfilingEnabled` | `false` | Experimental | Enable continuous memory profiling.
| `SPLUNK_PROFILER_LOGS_ENDPOINT`<br>`endpoint` | `http://localhost:4317` | Experimental | The OTLP logs receiver endpoint used for profiling data.
| `SPLUNK_PROFILER_LOGS_ENDPOINT`<br>`endpoint` | `http://localhost:4318` | Experimental | The OTLP logs receiver endpoint used for profiling data.
| `OTEL_SERVICE_NAME`<br>`serviceName` | `unnamed-node-service` | Stable | Service name of the application.
| `OTEL_RESOURCE_ATTRIBUTES` | | Stable | Comma-separated list of resource attributes. <details><summary>Example</summary>`deployment.environment=demo,key2=val2`</details>

Expand Down
4 changes: 2 additions & 2 deletions examples/profiling/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Profiling Example

This example showcases enabling profiling for Splunk APM. There's no official support for profiling in OTel, so profiling requires working with some Splunk-specific components.
By default, the example requires the OTel Collector to run with the OTLP receiver listening for logs on `localhost:4317`. To export profiling data to APM, you must set up `splunk_hec` exporter in the Collector. See [the example collector config](./collector-config.yml).
By default, the example requires the OTel Collector to run with the OTLP receiver listening for logs on `localhost:4318`. To export profiling data to APM, you must set up `splunk_hec` exporter in the Collector. See [the example collector config](./collector-config.yml).

```shell
# Replace <...> with the correct values
Expand All @@ -17,7 +17,7 @@ Then run the script in a separate terminal:
# Optional. To set the environment:
export OTEL_SERVICE_NAME='profiling-example'
export OTEL_RESOURCE_ATTRIBUTES='deployment.environment=dev'
export OTEL_LOG_LEVEL='DEBUG'
export OTEL_LOG_LEVEL=debug
# Run the example:
npm start
```
Expand Down
15 changes: 7 additions & 8 deletions examples/profiling/collector-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ receivers:
otlp:
protocols:
grpc:
signalfx:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318

exporters:
otlphttp:
Expand All @@ -12,22 +14,19 @@ exporters:
splunk_hec:
token: "${SPLUNK_ACCESS_TOKEN}"
endpoint: "https://ingest.${SPLUNK_REALM}.signalfx.com/v1/log"
logging/debug:
loglevel: debug
debug:
verbosity: detailed

processors:
batch:

service:
telemetry:
logs:
level: "debug"
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [logging/debug, otlphttp]
exporters: [debug, otlphttp]
logs/profiling:
receivers: [otlp]
processors: [batch]
exporters: [logging/debug, splunk_hec]
exporters: [debug, splunk_hec]
10 changes: 4 additions & 6 deletions examples/profiling/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
version: "3"
services:
otel-collector:
image: otel/opentelemetry-collector-contrib:0.50.0
image: quay.io/signalfx/splunk-otel-collector:0.111.0
environment:
- SPLUNK_CONFIG: /etc/otel/config.yml
- SPLUNK_ACCESS_TOKEN
- SPLUNK_REALM
command: ["--config=/etc/otel-collector-config.yml"]
volumes:
- ./collector-config.yml:/etc/otel-collector-config.yml
- ./collector.config.yml:/etc/otel/config.yml
ports:
- "9943:9943" # signalfx
- "4317:4317" # otlp
- "4318:4318" # otlp
11 changes: 3 additions & 8 deletions examples/profiling/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
const { start, stop } = require('@splunk/otel');
const { diag, DiagConsoleLogger, DiagLogLevel, trace, context } = require('@opentelemetry/api');

// If OTEL_LOG_LEVEL env var is set, configure logger
if (process.env.OTEL_LOG_LEVEL) {
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel[process.env.OTEL_LOG_LEVEL]);
}
const { trace, context } = require('@opentelemetry/api');

start({
// Tracing is enabled by default and is required for profiling
Expand All @@ -21,7 +16,7 @@ const doWork = () => {

// setTimeout has to be here because profiling is currently started asyncronously to avoid blocking the runtime.
// If we didn't we'd run stop before the profiling has started in the background.
setTimeout(() => {
setTimeout(async () => {
const tracer = trace.getTracer('splunk-otel-example-profiling');
const span = tracer.startSpan('main');
const spanContext = trace.setSpan(context.active(), span);
Expand All @@ -34,5 +29,5 @@ setTimeout(() => {
span.end();

// Stop profiling to flush the collected samples
stop();
await stop();
}, 10);
38 changes: 37 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@
},
"dependencies": {
"@grpc/grpc-js": "^1.11.1",
"@grpc/proto-loader": "^0.7.13",
"@opentelemetry/api": "^1.8.0",
"@opentelemetry/api-logs": "^0.53.0",
"@opentelemetry/context-async-hooks": "1.26.0",
"@opentelemetry/core": "1.26.0",
"@opentelemetry/exporter-logs-otlp-http": "0.53.0",
"@opentelemetry/exporter-logs-otlp-proto": "0.53.0",
"@opentelemetry/exporter-metrics-otlp-grpc": "0.53.0",
"@opentelemetry/exporter-metrics-otlp-proto": "0.53.0",
"@opentelemetry/exporter-trace-otlp-grpc": "0.53.0",
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export function createOtlpExporter(options: MetricsOptions) {
}
}

protocol = protocol ?? 'grpc';
protocol = protocol ?? 'http/protobuf';

switch (protocol) {
case 'grpc': {
Expand Down
Loading
Loading