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 auto instrumentation for winston #707

Closed
obecny opened this issue Jan 17, 2020 · 8 comments
Closed

Add auto instrumentation for winston #707

obecny opened this issue Jan 17, 2020 · 8 comments
Assignees

Comments

@obecny
Copy link
Member

obecny commented Jan 17, 2020

Weekly downloads: 3.8 mln
https://www.npmjs.com/package/winston

@pauldraper
Copy link
Contributor

pauldraper commented Mar 24, 2020

import opentelemetry from '@opentelemetry/api';
import { Format, format } from 'logform';
import { createLogger } from 'winston';

function tracingFormat(): Format {
  const tracer = opentelemetry.trace.getTracer('logform');
  return format(info => {
    const span = tracer.getCurrentSpan();
    if (span) {
      const context = span.context();
      info['trace.id'] = context.traceId;
      info['span.id'] = context.spanId;
    }
    return info;
  })();
}

const logger = createLogger({
  format: format.combine(tracingFormat(), format.json())
});

@vmarchaud
Copy link
Member

I think we can close this one since #736 has been closed ?

@dyladan dyladan closed this as completed Apr 25, 2020
@DisaPadla
Copy link

@pauldraper Hi. What is a solution for @opentelemetry/api@0.18.1 ? we don't have tracer.getCurrentSpan() anymore

@dyladan
Copy link
Member

dyladan commented Apr 8, 2021

@pauldraper Hi. What is a solution for @opentelemetry/api@0.18.1 ? we don't have tracer.getCurrentSpan() anymore

You can get the currently active span by doing

import { context, getSpan, Span } from "@opentelemetry/api";

const span: Span | undefined = getSpan(context.active());

@roastedmonk
Copy link

@pauldraper Hi. What is a solution for @opentelemetry/api@0.18.1 ? we don't have tracer.getCurrentSpan() anymore

You can get the currently active span by doing

import { context, getSpan, Span } from "@opentelemetry/api";

const span: Span | undefined = getSpan(context.active());

Will this not require span.end()?

@Flarna
Copy link
Member

Flarna commented Apr 21, 2021

Will this not require span.end()?

Nope, you get a reference to an existing span or undefined. No span is created/started here. As the span here is started by someone else the responsibly to end it is still there not here.

@janquijano
Copy link

What's the solution for 1.0.4? There's no getSpan anymore.

@Flarna
Copy link
Member

Flarna commented Apr 2, 2022

@janquijano it's still here, was moved from top level into trace namespace, see open-telemetry/opentelemetry-js-api#47

pichlermarc added a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this issue Dec 15, 2023
…sqs ReceiveMessage context handling (open-telemetry#1847)

In `@aws-sdk/client-sqs` v3.316 the SQS client methods became async. This breaks
the `utils.bindPromise` usage that attempts to propagate the SQS ReceiveMessage
span context to the user's handler for the method's returned promise.
Fixing that propagation is for open-telemetry#707 or another issue.

This change is a workaround that skips the testing of that span context
propagation feature.

Fixes: open-telemetry#1477
Refs: open-telemetry#707
Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants