This repository was archived by the owner on Jul 31, 2023. It is now read-only.
Add log exporter.#1126
Merged
rghetia merged 5 commits intocensus-instrumentation:devfrom Apr 23, 2019
Merged
Conversation
songy23
reviewed
Apr 23, 2019
examples/exporter/logexporter.go
Outdated
| // limitations under the License. | ||
|
|
||
| // Package exporter contains a log exporter that supports exporting | ||
| // OpenCensus metrics to a logging framework. |
examples/exporter/logexporter.go
Outdated
| "go.opencensus.io/trace" | ||
| ) | ||
|
|
||
| // LogExporter exports stats to log file |
examples/exporter/logexporter.go
Outdated
| // If it is nil then the metrics are logged on console | ||
| MetricsLogFile string | ||
|
|
||
| //TracesLogFile is path where exported span data are logged. |
|
|
||
| func printMetricDescriptor(metric *metricdata.Metric) string { | ||
| d := metric.Descriptor | ||
| return fmt.Sprintf("name: %s, type: %s, unit: %s ", |
Contributor
Author
There was a problem hiding this comment.
I print it as k=v pair in printLabels.
examples/exporter/logexporter.go
Outdated
| } | ||
| } | ||
|
|
||
| // Start starts the metric exporter. |
Contributor
Author
There was a problem hiding this comment.
it doesn't start trace exporter. For trace it sill requires to register but I don't see why I cannot call registerExporter here. I'll make the change and update the comment.
examples/exporter/logexporter.go
Outdated
| return e.ir.Start() | ||
| } | ||
|
|
||
| // Stop stops the metric exporter. |
| e.ir, _ = metricexport.NewIntervalReader(&metricexport.Reader{}, e) | ||
| }) | ||
| e.ir.ReportingInterval = e.o.ReportingInterval | ||
| return e.ir.Start() |
Contributor
There was a problem hiding this comment.
Do you need to register this as a trace exporter too?
Contributor
Author
There was a problem hiding this comment.
I'll register as trace exporter here. see my response to prev comment.
songy23
approved these changes
Apr 23, 2019
examples/exporter/logexporter.go
Outdated
| } | ||
| f, err := os.OpenFile(filepath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) | ||
| if err != nil { | ||
| log.Fatalf("error opening file: %v", err) |
Contributor
There was a problem hiding this comment.
Nit: consider returning err instead of logging it.
rghetia
added a commit
to rghetia/opencensus-go
that referenced
this pull request
Apr 25, 2019
* Add log exporter. * close log files when program terminates. * split stats into multiple lines. * fix review comments. * one more comment.
rghetia
added a commit
that referenced
this pull request
Apr 25, 2019
* Add log exporter. * close log files when program terminates. * split stats into multiple lines. * fix review comments. * one more comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.