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

add instrumentation & set key env #12

Closed
wants to merge 1 commit into from
Closed
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: 6 additions & 2 deletions src/frontend/utils/telemetry/HoneycombFrontendTracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations-web';
import { HoneycombWebSDK } from '@honeycombio/opentelemetry-web';
import { HoneycombWebSDK, WebVitalsInstrumentation } from '@honeycombio/opentelemetry-web';
// ^ on github we use this, in the docs we omit WebVitals and do it piecemeal. IMO this should be explained if they're going to stay different.
import {SessionIdProcessor} from "./SessionIdProcessor";


Expand All @@ -12,9 +13,11 @@ const { NEXT_PUBLIC_OTEL_SERVICE_NAME = '', NEXT_PUBLIC_OTEL_EXPORTER_OTLP_TRACE
const FrontendTracer = async () => {
const sdk = new HoneycombWebSDK({
skipOptionsValidation: true, // because we are not including apiKey
// but WHY aren't we? It's because we're not direct sending to api, we're using the collector
serviceName: NEXT_PUBLIC_OTEL_SERVICE_NAME,
spanProcessor: new SessionIdProcessor(),
endpoint: NEXT_PUBLIC_OTEL_EXPORTER_OTLP_TRACES_ENDPOINT || 'http://localhost:4318/v1/traces',
// this will be updated to the CA collector once instrumentation is expanded and this is moved to k8s
instrumentations: [getWebAutoInstrumentations({
'@opentelemetry/instrumentation-fetch': {
propagateTraceHeaderCorsUrls: /.*/,
Expand All @@ -23,7 +26,8 @@ const FrontendTracer = async () => {
span.setAttribute('app.synthetic_request', IS_SYNTHETIC_REQUEST);
},
},
})], // add automatic instrumentation
}), new WebVitalsInstrumentation()], // add automatic instrumentation
// ^ update docs to explain what this means, it's supposed to mean that more instrumentation (like webvitals) should be added there, but it isn't clear imo.
});
sdk.start();
};
Expand Down
10 changes: 8 additions & 2 deletions src/otelcollector/otelcol-config-extras.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@

# extra settings to be merged into OpenTelemetry Collector configuration
# do not delete this file

extraEnvs:
- name: HONEYCOMB_API_KEY
valueFrom:
secretKeyRef:
name: honeycomb
key: api-key

exporters:
otlp/honeycomb:
endpoint: "api.honeycomb.io:443"
headers:
"x-honeycomb-team": "<HONEYCOMB_API_KEY>"
"x-honeycomb-team": "${HONEYCOMB_API_KEY}"
"x-honeycomb-dataset": "webstore-metrics"

service:
Expand Down
Loading