-
Notifications
You must be signed in to change notification settings - Fork 635
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
Adding metric collection as part of instrumentations - Requests #1116
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e7f9183
duration
lzchen d7f771e
tests
lzchen c17732b
changelog
lzchen b85c02a
fix build
lzchen 66890b5
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
lzchen 250422e
fix tests
lzchen d36979c
lint
lzchen daef875
fix build
lzchen 94bedde
lint
lzchen adaeee3
lint
lzchen 8378400
lint
lzchen 6db3175
lint
lzchen 3157ef8
space
lzchen 3b65383
lint
lzchen 43ccc7a
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
lzchen ea883d3
comments
lzchen 58ace95
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
lzchen b93342c
lint
lzchen ff4c491
lint
lzchen 195d876
lint
lzchen 06b7fde
Update metric.py
lzchen d24043a
lint
lzchen b21da84
Update __init__.py
lzchen 7ec6590
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
lzchen 6076bab
Update __init__.py
lzchen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
""" | ||
This module shows how you can enable collection and exporting of http metrics | ||
related to instrumentations. | ||
""" | ||
import requests | ||
|
||
from opentelemetry import metrics | ||
from opentelemetry.instrumentation.requests import RequestsInstrumentor | ||
from opentelemetry.sdk.metrics import MeterProvider | ||
from opentelemetry.sdk.metrics.export import ConsoleMetricsExporter | ||
|
||
# Sets the global MeterProvider instance | ||
metrics.set_meter_provider(MeterProvider()) | ||
|
||
# Exporter to export metrics to the console | ||
exporter = ConsoleMetricsExporter() | ||
|
||
# Instrument the requests library | ||
RequestsInstrumentor().instrument() | ||
|
||
# Indicate to start collecting and exporting requests related metrics | ||
metrics.get_meter_provider().start_pipeline( | ||
RequestsInstrumentor().meter, exporter, 5 | ||
) | ||
|
||
response = requests.get("http://example.com") | ||
|
||
input("...\n") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ Submodules | |
:maxdepth: 1 | ||
|
||
instrumentor | ||
metric |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
opentelemetry.instrumentation.metric package | ||
============================================ | ||
|
||
.. automodule:: opentelemetry.instrumentation.metric | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
Is it possible to infer http.scheme as well here using url?
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. However, if
url
is available, it takes priority since all components of the URI can be derived from it. See https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/metrics/semantic_conventions/http-metrics.md#parameterized-labels