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.
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.
Do you want to publish this package to npm? If no, can we add private: true?
There was a problem hiding this comment.
Because looks like real use case is for unit testing only, right?
There was a problem hiding this comment.
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.
Makes sense. I thought, intention was to use in this project only.
There was a problem hiding this comment.
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.
Optional: remove the extra space
|
|
||
| /** Object Exporter manager class */ | ||
| export class ObjectTraceExporter implements Exporter { | ||
| buffer: ExporterBuffer; |
There was a problem hiding this comment.
To fix the build either make this variable public or remove check on buffer queue length.
| */ | ||
| onEndSpan(span: Span) { | ||
| this.endedSpans.push(span); | ||
| this.buffer.addToBuffer(span); |
There was a problem hiding this comment.
Just curious to know the usage of buffer here.
There was a problem hiding this comment.
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.
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-exporterthat stores started, ended and published spans in memory and makes them accessible.