Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Conversation

@lzchen
Copy link
Contributor

@lzchen lzchen commented Jul 28, 2021

Implement statsbeat feature, only supporting attach rate metrics.
NOTE: Heartbeat metrics was partially implemented previously for attach rate metrics, but now is encapsulated into stats, hence the rename.

TODO:
Network metrics
Feature metrics
Secure with AAD

@heyams
@hectorhdzg

@lzchen lzchen requested review from a team, aabmass, hectorhdzg and songy23 as code owners July 28, 2021 18:58
@google-cla google-cla bot added the cla: yes label Jul 28, 2021
@@ -1,132 +0,0 @@
# Copyright 2019, OpenCensus Authors

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing heartbeat?, I believe is still relevant and is not being replaced by Statsbeat

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heartbeat was never fully implemented/committed for OpenCensus Python. There are no current plans to implement them either.

if self._is_stats:
envelope.name = "Statsbeat"
else:
envelope.name = "Microsoft.ApplicationInsights.Metric"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can save payload by sending "Metric" directly for regular custom metrics.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly. The benefit of saving the payload doesn't really outweigh the need to change unrelated code.

from opencensus.ext.azure.metrics_exporter import MetricsExporter
from opencensus.ext.azure.metrics_exporter.heartbeat_metrics.heartbeat import (
HeartbeatMetric,
from opencensus.ext.azure.metrics_exporter.statsbeat_metrics.statsbeat import (
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Statsbeat is not a replacement of heartbeat. Might want to keep Hearbeat metrics. they're very diff.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i realized statsbeat_metrics.statsbeat is not a package name.. rather the class name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

properties.append(LabelKey("runtimeVersion", 'Python version'))
properties.append(LabelKey("os", 'os of application being instrumented'))
properties.append(LabelKey("language", 'Python'))
properties.append(LabelKey("version", 'version of exporter package'))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version is for python sdk's verison.. it's not clear to me if they're the same thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We are using sdkVersion to represent this. For OpenCensus Python, that would look like pyX:ocY:extZ, X being the python version, Y being the OpenCensus version and Z being the exporter version.

return properties


class _StatsbeatMetrics:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AttachStatsbeat?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so that it's easier to control enablement/disablement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If enablement/disablement is done through environment variables, separate classes will be unnecessary. Will probably revisit once we fully spec out enable/disable.

properties.append(LabelValue("python")) # language
# version
properties.append(
LabelValue(azure_monitor_context['ai.internal.sdkVersion']))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should customMetrics handle this by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heyams I'm not sure I understand. Handle what by default? customMetrics is an Azure concept. LabelValue is an OpenCensus metrics concept.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your telemetry client (not sure how you call it) should handle that for all telemetries to Breeze. this is required for all telemetries sent to breeze. I'm saying you should not do it specifically for statsbeat.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the this is already being handled here which populates the tags dict in breeze. The logic here in specific for stats because we also want version to be populated as a custom_dimension correct?

@heyams
Copy link

heyams commented Jul 28, 2021

curious to know how you handle batching in python.. statsbeat's endpoint is diff from the customer's ikey endpoint.. all statsbeat will be batched together and send to its own endpoint... using customer's endpoint to send statsbeat will result failure.

@heyams
Copy link

heyams commented Jul 28, 2021

Another suggestion: please make statsbeat connection string configurable so that your testing data will go to your testing statsbeat endpoint. and you can control interval for faster testing.

Copy link

@hectorhdzg hectorhdzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lzchen
Copy link
Contributor Author

lzchen commented Jul 28, 2021

Another suggestion: please make statsbeat connection string configurable so that your testing data will go to your testing statsbeat endpoint. and you can control interval for faster testing.

Added an environment variable to configure this. APPLICATION_INSIGHTS_STATS_CONNECTION_STRING and APPLICATION_INSIGHTS_STATS_SHORT_EXPORT_INTERVAL

@lzchen
Copy link
Contributor Author

lzchen commented Jul 29, 2021

curious to know how you handle batching in python.. statsbeat's endpoint is diff from the customer's ikey endpoint.. all statsbeat will be batched together and send to its own endpoint... using customer's endpoint to send statsbeat will result failure.

@heyams
There is a separate MetricsExporter that is constructed for customer and for statsbeat, and they both exist in different threads. The metrics telemetry generated are completely separate and batched separately so no issues there with conflicts.

@lzchen lzchen merged commit 6e522f7 into census-instrumentation:master Jul 29, 2021
@lzchen lzchen deleted the stats branch July 29, 2021 20:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants