This repository was archived by the owner on Oct 3, 2023. It is now read-only.
Initialize the labels map in the response.#264
Merged
nilebox merged 1 commit intocensus-ecosystem:masterfrom Jun 16, 2020
Merged
Initialize the labels map in the response.#264nilebox merged 1 commit intocensus-ecosystem:masterfrom
nilebox merged 1 commit intocensus-ecosystem:masterfrom
Conversation
Fixes the following error when the `labels` is not initialized: ``` Container logs: level=info ts=2020-03-02T03:17:42.590Z caller=main.go:293 msg="Starting Stackdriver Prometheus sidecar" version="(version=0.7.3, branch=master, revision=2548e8a7b383adc9217afe8570247ea84e3ef2c0)" level=info ts=2020-03-02T03:17:42.591Z caller=main.go:294 build_context="(go=go1.12, user=kbuilder@kokoro-gcp-ubuntu-prod-40088225, date=20200206-15:24:17)" level=info ts=2020-03-02T03:17:42.591Z caller=main.go:295 host_details="(Linux 4.14.138+ census-ecosystem#1 SMP Tue Sep 3 02:58:08 PDT 2019 x86_64 apigee-metrics-v111-fd6fj (none))" level=info ts=2020-03-02T03:17:42.592Z caller=main.go:296 fd_limits="(soft=1048576, hard=1048576)" panic: assignment to entry in nil map ``` Labels can be optionally extracted from OC_RESOURCE_TYPE and OC_RESOURCE_LABELS env vars (https://github.com/census-instrumentation/opencensus-go/blob/1901b56b9515b0c34f5d25a5bce982dfc543d64b/resource/resource.go#L30). In case those envs are not set, labels will not be initialized: https://github.com/census-instrumentation/opencensus-go/blob/1901b56b9515b0c34f5d25a5bce982dfc543d64b/resource/resource.go#L98 For the case here, we are in fact sending metrics to Stackdriver. So OC_RESOURCE_TYPE and OC_RESOURCE_LABELS may not be needed. But we should init the Labels field.
Codecov Report
@@ Coverage Diff @@
## master #264 +/- ##
==========================================
- Coverage 72.02% 71.94% -0.09%
==========================================
Files 17 17
Lines 1691 1693 +2
==========================================
Hits 1218 1218
- Misses 397 399 +2
Partials 76 76
Continue to review full report at Codecov.
|
nilebox
approved these changes
Jun 16, 2020
qingling128
added a commit
to Stackdriver/stackdriver-prometheus-sidecar
that referenced
this pull request
Sep 18, 2020
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.
Fixes the following error when the
labelsis not initialized:Labels can be optionally extracted from OC_RESOURCE_TYPE and OC_RESOURCE_LABELS env vars (https://github.com/census-instrumentation/opencensus-go/blob/1901b56b9515b0c34f5d25a5bce982dfc543d64b/resource/resource.go#L30). In case those envs are not set, labels will not be initialized: https://github.com/census-instrumentation/opencensus-go/blob/1901b56b9515b0c34f5d25a5bce982dfc543d64b/resource/resource.go#L98
For the case here, we are in fact sending metrics to Stackdriver. So OC_RESOURCE_TYPE and OC_RESOURCE_LABELS may not be needed. But we should init the Labels field.