-
Notifications
You must be signed in to change notification settings - Fork 96
Object Trace Exporter for programatic span access #564
Object Trace Exporter for programatic span access #564
Conversation
[![Gitter chat][gitter-image]][gitter-url] | ||
|
||
OpenCensus Object Trace Exporter allows the user to collect and | ||
programatically access traces with [OpenCensus Node.js](https://github.com/census-instrumentation/opencensus-node). This module is useful for when you need |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: s/programatically/programmatically/g
{ | ||
"name": "@opencensus/exporter-object", | ||
"version": "0.0.13", | ||
"description": "OpenCensus Object Exporter allows the user to collect and access traces with OpenCensus Node.js.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to publish this package to npm? If no, can we add private: true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because looks like real use case is for unit testing only, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How could a developer consume it without npm? I'd expect it will be installed as a dev dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I thought, intention was to use in this project only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, sorry for not explaining the context well. I meant testing instrumentation in external services, My use case is that I instrumented an application with OpenCensus and now I want to be sure it collects the right spans during the application lifecycle. I could stub on Tracer internals but I feel it would be a cleaner approach.
|
||
import {CoreTracer, Span, SpanKind, TracerConfig} from '@opencensus/core'; | ||
import * as assert from 'assert'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: remove the extra space
|
||
/** Object Exporter manager class */ | ||
export class ObjectTraceExporter implements Exporter { | ||
buffer: ExporterBuffer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be a private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To fix the build either make this variable public or remove check on buffer queue length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build fixed.
*/ | ||
onEndSpan(span: Span) { | ||
this.endedSpans.push(span); | ||
this.buffer.addToBuffer(span); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious to know the usage of buffer
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing something from how OpenCensus works. I thought core module calls publish with buffer content externally. Am I correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, correct. Earlier, I didn't understand the context well, thanks for explaining #564 (comment). Ignore this comment.
Codecov Report
@@ Coverage Diff @@
## master #564 +/- ##
=========================================
- Coverage 95.3% 95.21% -0.1%
=========================================
Files 148 149 +1
Lines 10590 10510 -80
Branches 745 743 -2
=========================================
- Hits 10093 10007 -86
- Misses 497 503 +6
Continue to review full report at Codecov.
|
@hekike https://www.npmjs.com/package/@opencensus/exporter-object is avaiable in npm after latest release (0.0.14). |
Thank you! |
I'm considering to use an in-memory exporter approach for unit testing.
This PR adds an
object-exporter
that stores started, ended and published spans in memory and makes them accessible.