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

Extract byte size from proto-plus messages#976

Merged
aabmass merged 3 commits intocensus-instrumentation:masterfrom
aabmass:protoplus-grpc-969
Dec 8, 2020
Merged

Extract byte size from proto-plus messages#976
aabmass merged 3 commits intocensus-instrumentation:masterfrom
aabmass:protoplus-grpc-969

Conversation

@aabmass
Copy link
Copy Markdown
Member

@aabmass aabmass commented Nov 19, 2020

Fixes #969

Recommendation for getting the byte size here: googleapis/proto-plus-python#163

@google-cla google-cla bot added the cla: yes label Nov 19, 2020
@aabmass aabmass changed the title extract byte size from proto-plus messages WIP extract byte size from proto-plus messages Nov 19, 2020
@aabmass aabmass changed the title WIP extract byte size from proto-plus messages Extract byte size from proto-plus messages Nov 25, 2020
@aabmass aabmass force-pushed the protoplus-grpc-969 branch 2 times, most recently from c31fc7d to 0dd0a98 Compare November 25, 2020 23:34
@aabmass aabmass marked this pull request as ready for review November 25, 2020 23:35
@aabmass
Copy link
Copy Markdown
Member Author

aabmass commented Dec 8, 2020

Just doing some testing on this before merging

@aabmass
Copy link
Copy Markdown
Member Author

aabmass commented Dec 8, 2020

Did some manual testing, working as expected with proto-plus versions of a GCP client lib (used google-cloud-secret-manager==2.1.0):

import time

from google.cloud.secretmanager_v1.types.service import (
    AccessSecretVersionRequest,
)
from opencensus.trace.tracer import Tracer
from opencensus.trace.samplers import AlwaysOnSampler
from opencensus.trace import config_integration
from opencensus.ext.stackdriver.trace_exporter import StackdriverExporter
from opencensus.common.transports.async_ import AsyncTransport
from functools import partial
from google.cloud.secretmanager_v1.services.secret_manager_service import (
    SecretManagerServiceClient,
)


config_integration.trace_integrations(["google_cloud_clientlibs"])

tracer = Tracer(
    exporter=StackdriverExporter(transport=partial(AsyncTransport, wait_period=5.0)),
    sampler=AlwaysOnSampler(),
)


def main() -> None:
    secret_client = SecretManagerServiceClient()

    secret = secret_client.access_secret_version(
        AccessSecretVersionRequest(
            name="projects/<projectid>/secrets/fake-secret/versions/1"
        )
    ).payload.data.decode()
    print("Got secret: {}".format(secret))
    time.sleep(6)


if __name__ == "__main__":
    main()

And I see the byte size annotations in Cloud trace: Screen Shot 2020-12-08 at 10 52 50 AM

@aabmass aabmass merged commit a3931d9 into census-instrumentation:master Dec 8, 2020
@aabmass aabmass deleted the protoplus-grpc-969 branch December 8, 2020 17:55
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.

Incompatibility With Recent GCP SDK Versions

2 participants