Commit Graph

234 Commits

Author SHA1 Message Date
Takashi Kajinami 0f9d1372d6 Declare Python 3.10 support
... and removes the remaining code and dependency for Python < 3.8.

Change-Id: I305d3b9cc43bedf980826b10ab26959d10e35997
2023-10-07 12:06:39 +09:00
Sahid Orentino Ferdjaoui 3c5feadda2 profiler: add python requests profile
Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@industrialdiscipline.com>
Change-Id: I00e9f5661a3bd54acc846e8c326896d21e70be36
2023-06-01 08:44:08 +02:00
Sahid Orentino Ferdjaoui 908e740232 add support of otlp exporter
Depends-On: Idcff5d79b4884dd1cc7ed1ab42c9e4ce89d4a6d2
Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@industrialdiscipline.com>
Change-Id: I74cdcb2aa99b0162ba1c14059111f09d0bb534e3
2023-05-10 10:18:48 +02:00
Takashi Kajinami 3c9e7d9aeb [profiler] hmac_key should be secret
... apparently because the parameter takes secret key(s) for data
encryption.

Change-Id: I76836aa2a99549b23174f1869cc09fbf0c30681b
2023-03-23 00:54:50 +09:00
Zuul 4239bcaa56 Merge "Change StrictRedis usage to Redis" 2023-02-17 13:43:33 +00:00
Sahid Orentino Ferdjaoui 91d7c35f1c jaeger: introduce process tags' option for tracer
Closes-bug: 2006611
Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@industrialdiscipline.com>
Change-Id: I938b52d7785d421015b888c9d70a5b0bf032772f
2023-02-16 12:17:31 +00:00
Sahid Orentino Ferdjaoui b7468756bc jaeger: introduce service name prefix
Closes-bug: #2003092
Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@industrialdiscipline.com>
Change-Id: I743fdc1203af6735d5772728e1b5c2ca16d41d9e
2023-02-16 09:08:50 +01:00
Sahid Orentino Ferdjaoui 9f50374dde jaeger: fix driver initialization for tests
The initializator is a singleton, we should release driver after each
setUp.

Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@industrialdiscipline.com>
Change-Id: If6728f792609d1dc59d86954a767afe802c435e3
2023-02-16 09:08:49 +01:00
Tobias Urdin f8d80022f3 Change StrictRedis usage to Redis
The StrictRedis class is only an alias for
Redis in >= 3.0.0

Change-Id: I5b72306ec2d3164b285c24190c0d3f9ced4b6a31
2023-02-08 10:53:26 +00:00
Michael Johnson b9206a5349 Fix api index and module index
This patch fixes the index and module index for the osprofiler documentation
home page.
It also updates the documents tox environments to use a docs requirements.txt

Change-Id: I880f1c28232a299f50ea9ccc2178f1444efb9a41
2022-02-17 22:35:09 +00:00
wangzihao adc39e86ac Remove six
Remove six Replace the following items with Python 3 style code.
- six.moves
- six.StringIO
- six.add_metaclass
- six.string_types
- six.binary_type
- six.text_type
- six.integer_types
- six.PY3
- six.PY2
- six.iterkeys

Change-Id: Id9f2076be1a6a2d99db5acb682df8bebe893de36
2020-12-17 17:51:56 +08:00
Hervé Beraud 2794b9828c Adding pre-commit
Introduced changes:
- pre-commit config and rules
- Add pre-commit to pep8 gate, Flake8 is covered in the pre-commit hooks.
- Applying fixes for pre-commit compliance in all code.

Also commit hash will be used instead of version tags in pre-commit to
prevend arbitrary code from running in developer's machines.

pre-commit will be used to:
- trailing whitespace;
- Replaces or checks mixed line ending (mixed-line-ending);
- Forbid files which have a UTF-8 byte-order marker (check-byte-order-marker);
- Checks that non-binary executables have a proper
  shebang (check-executables-have-shebangs);
- Check for files that contain merge conflict strings (check-merge-conflict);
- Check for debugger imports and py37+ breakpoint()
  calls in python source (debug-statements);
- Attempts to load all yaml files to verify syntax (check-yaml);
- Run flake8 checks (flake8) (local)

For further details about tests please refer to:
https://github.com/pre-commit/pre-commit-hooks

Change-Id: If4bd505d6bf73d06ce2f6080cedb3b5576c881d9
Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
2020-10-09 11:07:15 +02:00
Manish Kumar 5d82a02507 Fix StopIteration error on Ubuntu Focal
As per victoria cycle testing runtime and community goal,
we need to migrate upstream CI/CD to Ubuntu Focal(20.04).

StopIteration error happening in pep8 job when running on Focal.

we can see the failure in https://review.opendev.org/#/c/744331/

Change-Id: Iecdd3bfddb95adec77f8581f844cfc74ca59fc73
Story: #2007865
Task: #402207
2020-09-06 14:14:09 +00:00
Doug Hellmann e8dd381e62 switch to importlib.metadata to find package version
Importing pkg_resources has a side-effect of reading all of the
metadata for every installed python package. The newer
importlib.metadata module can load the metadata for one package at a
time, which makes this library load more quickly and improves the
startup-time performance of applications that use it such as
python-openstackclient.

importlib.metadata is part of the python 3.8 standard library and is
distributed separately for other versions of python.

Change-Id: Ib1870a3d102116f84c7677601fd44fdac41a13a6
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2020-07-06 11:07:17 +02:00
Daria Kobtseva 61a0ff8ace Fix empty 'args' and 'kwargs' when using 'hide_args' with Jaeger
When 'hide_args=True' is used in @profiler.trace() decorator
along with Jaeger driver, trace 'args' and 'kwargs' function
parameters are empty, which leads to a key error.

This change introduces a key check before adding those parameters to
tags.

Change-Id: I312da1b175a04d4ddee7f823111b8320dd4777d6
2020-06-21 12:29:42 +02:00
Andreas Jaeger 1d77244f18 Fix pep8 failures
With an updated flake8, we get some new warnings. Update hacking
directly to version 3.1.0 and fix the problems found.

Note that before this change, flake8 used the default "ignore" list,
this now adds a new ignore list.

Change-Id: Iccbf4f30eb4e542d3824b7782f43eacda29c5a90
2020-06-02 17:07:50 +02:00
Ilya Shakhat 3fc760ad24 Enforce order of import statements
This patch adds flake8-import-order plugin and fixes
all found issues.

Change-Id: Ibbeae4afeb737401de48fb2e7e225eb0a969908b
2020-04-20 12:43:51 +02:00
Sean McGinnis 6a4d27f7b7
Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I76e01d55ff4d9095a6dbf520752042824225de73
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-04-18 11:57:01 -05:00
Andreas Jaeger 6e6d76aafe Update hacking for Python3
The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix problems found.

Update local hacking checks for new flake8.

Change-Id: I8ba89483c8e6b76011833cfc5080eab3fd269c8b
2020-04-01 11:18:56 +02:00
Zuul e022fdaa8e Merge "Handle driver initialization errors to avoid service crash" 2019-11-18 17:24:16 +00:00
Ilya Shakhat 34ca7ab4b5 Handle driver initialization errors to avoid service crash
This patch fixes the issue when failed osprofiler driver brings
the whole service down. With this patch the default no-op behaviour
is used in case of initialization failure.

Change-Id: I6ebc393576f4fc3f8b4134164bafc2e09f102ebd
2019-07-24 17:02:28 +02:00
francotseng ede0ec402e Bring env OSPROFILER_CONNECTION_STRING into effect
The --connection-string is marked required, and parse_args()
assumes the flag invalid if it's not supplied as command line
argument, even if env OSPROFILER_CONNECTION_STRING is setted.

We should not rely on the required=True of argparse module,
but check the required args on our own to take env arguments
into consideration.

Change-Id: I50f5f369ec41ddc82f9b66f5910b7805940fb387
2019-06-28 14:18:28 +08:00
Zuul 84f164d923 Merge "Optimize storage schema for Redis driver" 2019-05-20 09:36:26 +00:00
Ilya Shakhat 0fcc65d0d5 Automatic configuration of SQLAlchemy driver in DevStack
This patch adds a new type of collector "sqlalchemy".
To enable it, add the following line into DevStack local.conf:

    OSPROFILER_COLLECTOR=sqlalchemy

OSProfiler DevStack plugin creates database for traces and
configures all services to use it.

SQLAlchemy driver is extend to be able to list traces.

Zuul job is added to run Tempest tests with sqlalchemy driver enabled.

Change-Id: Ia943d311d78f6dfd2e6bb884c8dca725b3b2a36b
2019-05-16 12:03:00 +02:00
XiaojueGuan 5386d7c40c change function list_traces of mongodb module
osprofiler fails when it is configed with mongon.
the minimum version of pymongo osprofile requires is 3.0.2
and in this version and after when function list_traces is
is invoked error will show described in the bug issue.

Change-Id: I2510660c36aaa89117a97c67b4cb61fa3dade14d
Closes-Bug: 1827480
2019-05-03 15:53:06 +08:00
Ilya Shakhat 147effea78 Optimize storage schema for Redis driver
The original Redis driver stored each tracing event under its own key,
as result both list and get operations required a full scan of the database.
With this patch traces are stored as Redis lists under a key equal
to trace id. So list operation iterates only over unique trace ids
and get operation retrieves the content of a specified list. Note that
list operation still needs to retrieve at least 1 event from the trace
in order to get a timestamp.

Performance test is executed with 1000 traces each consisting 1000 events:
 * existing driver:
   * write: 48 sec
   * list:  41 sec
   * get:   3.6 sec
 * optimized driver:
   * write: 44 sec
   * list:  4.1 sec
   * get:   0.01 sec

Change-Id: I09a122f91e3d26531965fe53d6df7c66f502de4c
2019-04-09 13:27:18 +02:00
Thomas Bechtold add4794120 Don't fail if sqlalchemy driver fails to initialize
Given that the driver is initialized during the service
startup (eg. like Keystone, Nova, ...) a osprofiler driver failure has
a huge impact on the service (when the driver fails, the whole service
is not usable).
We want to avoid that and just log error/exceptions but keep the
services running.

Change-Id: I5688f10364884a74b7eb44c0c8bda15730ccd424
Closes-Bug: 1819433
2019-03-19 13:12:45 +01:00
Thomas Bechtold 032a218618 Add sqlalchemy collector
Beside the already available collectors, add a sqlalchemy based
collector. This is useful if you don't want to maintain another DB
solution and just use the (usually) already available database.
The driver currently implements the notify() and get_report() methods
so it is possible to store trace points and to get a single trace.

Change-Id: If91b35d4b97862c0ecf6677f4c6b95a09d411195
2019-02-14 11:34:05 +01:00
Shoham Peller de5f31650e In case of an error, always add message
The Jaeger driver counts on this message to be in the error description.
It fails if the message is not present

Closes-Bug: 1804218
Change-Id: I08f8328700049d9a0d791b12375fe9a6e8a3948a
2018-12-16 15:48:15 +02:00
Shoham Peller 1a18d0f944 When shortening span-ids, check if they're already short
If you're given an int, there's nothing to do, just return it

Change-Id: I289dab8cfabaecf243fdc16b972695e83c83c3e4
Closes-Bug: 1795664
Signed-off-by: Shoham Peller <shohamp@gmail.com>
2018-10-09 07:37:11 +03:00
lipan 98238b48c7 add password for connecting redis-sentinel
Change-Id: Ic244a3028d9c4c189a58ddc76cd59d9f9d5aeea7
Close-Bug: #1787342
2018-09-01 14:21:25 +00:00
Stuart Grace dba75673af Make profiler.clean() public method
Horizon dashboard has a profiler plugin which calls profiler.init
method at
 openstack_dashboard/contrib/developer/profiler/middleware.py
line 64. This creates a profiler and picks a new base_id. The only
way to remove this profiler and stop using this base_id is to call
profiler._clean() method. So this patch changes _clean() to clean()
so it becomes a public method.

Change-Id: Idec7ee240bc7f508aeebcba374a9673652b1cc72
Related-Bug: #1777486
2018-06-27 12:26:55 +01:00
Zuul 4bec736b18 Merge "opts: Fix invalid rST formatting" 2018-06-26 12:20:07 +00:00
Stephen Finucane 9cc4066892 opts: Fix invalid rST formatting
Resolve the following warnings issue when the opts are included in
documentation with 'oslo_config.sphinxext'.

  WARNING: Bullet list ends without a blank line; unexpected unindent.

Some other minor issues are addressed in the process.

Change-Id: I6cb2da083b1051c9aa39f72352cbc0c35e5592bb
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2018-06-26 04:02:01 +00:00
Nguyen Van Duc 5ea78ce950 Put 'db' parameter back and provide a deprecation warning before remove
The parameter should have been deprecated before its removal to give
callers a chance to adjust their calls to the new argument list.

This patchset follows Ben Nemec's comment in commit
https://review.openstack.org/#/c/569078/

Change-Id: I606796a33f6304276fe78b9868239a0ee5b9f46a
2018-06-26 04:01:41 +00:00
Zuul eb6376c052 Merge "OSprofiler with Jaeger Tracing as backend" 2018-06-13 22:01:47 +00:00
Ilya Shakhat 56e5ce42e7 Allow user to specify password for Redis connection
Support full schema for connection to Redis: make port number
optional, allow password and database number. The schema is following:
`redis://[:password]@host[:port][/db]`

Change-Id: I0f8be615aa95409653211b24e114d8b0870b2afa
Closes-Bug: #1768742
2018-06-01 10:32:34 +07:00
Tovin Seven 513a7c88a7 OSprofiler with Jaeger Tracing as backend
In this patch, I use Uber Jaeger as a tracer.
Trace/span from OSprofiler will be sent to Jaeger.
We can use Jaeger UI to view trace.

A sample image of trace in Jaeger:
https://tovin07.github.io/opentracing/jaeger-openstack-image-list.png

Reference:
- OpenTracing: http://opentracing.io/
- Uber Jager: https://www.jaegertracing.io/docs/

Depends-On: Iaac3ac3853867a67f7e386e762e0522076235daf

Change-Id: I8f75af487f50d5e67a1321a4c951d2a0d85733a1
Implements: blueprint opentracing-compatible
2018-05-29 06:03:46 +00:00
Tovin Seven 113a2ddddd Filter traces that contain error/exception
Adds ability to filter error traces to OSProfiler.
Adds command for list error traces.

Change-Id: I0ec97337cae5e573fedae2b6665aa73a73fe3654
2018-02-05 15:14:17 +07:00
Zuul ab01236a69 Merge "Unify and fix `list_traces` function" 2018-01-24 06:16:42 +00:00
Zuul 22c1a99209 Merge "Add initial 'trace list' command" 2018-01-24 05:59:50 +00:00
Zuul 252c14633a Merge "Check profiler instance before initialize" 2018-01-23 17:52:23 +00:00
Ilya Shakhat d2c1bb5ffa Unify and fix `list_traces` function
1. Remove `filter` parameter from `list_traces` function, since
   filtering is heavily depends on a backend and cannot be (easily)
   made uniform.
2. Unify the output of `list_traces` - the function returns a list
   of `traces`, where each trace is a dictionary with at least `base_id`
   and `timestamp` fields.
3. Fix `list_traces` in Redis driver, so it returns only traces, instead
   of events.
4. Add functional test for `list_traces` in Redis driver.

Change-Id: Ia81540288fe98fd9b8e256c62cc372fa33fcbea3
2018-01-23 13:31:51 +01:00
Omer Anson 23ab27ad38 Add initial 'trace list' command
This is an initial trace list command, which acts both as a
starting-point, as well as an immediate solution for anyone
who needs the basic functionality of this feature.

Change-Id: I99ad62103914b047cfc3c33e50ae98b6a0d01d6d
Related-Bug: #1733232
2018-01-23 13:31:04 +01:00
Ilya Shakhat 0bb909c7a0 Remove Ceilometer support
Our current Ceilometer driver relies on old version of ceilometer client,
which is in deprecated state and not compatible with the latest Telemetry
projects (Panko, Gnocchi). The functionality of the driver is not tested
automatically and most probably broken. So it's time to let it go and
clean the code.

This patch leaves "messaging" driver as default for notification and
makes "connection-string" a required parameter in CLI. In the future
we may consider to change default notification driver, though it
requires proper release note handling in all affected projects.

Change-Id: Id8442c4ff13c5cc33fd909b4757757cc5f396f50
2018-01-18 12:01:09 +01:00
Tovin Seven 79e4e2de42 Check profiler instance before initialize
Add a small check for this to an prevent issue in Nova [1]
that causes some commands not working.

[1] http://paste.openstack.org/show/641262/

Change-Id: I685386695e13bf5034a1008dbdcff4539eb482d2
Closes-Bug: #1743586
2018-01-18 15:22:07 +07:00
Zuul 3370658fb3 Merge "Add kwargs to WsgiMiddleware __init__" 2018-01-02 10:06:19 +00:00
Tovin Seven 7de2bf8835 Add filter for OSprofiler html output
This patch help us filter some spans in html output
using angular-ui-tree-filter (MIT license) with regular expression.

Currently, this work help us filter:
    - name
    - project
    - service
    - host
We can add more fields as we need.

Demo:
    - Small trace: https://tovin07.github.io/osprofiler-filtration/pretty-simple.html
    - Large trace: https://tovin07.github.io/osprofiler-filtration/very-large.html

Change-Id: I78ff242fce3e0cf07b9e4969b783e32d9529c581
2018-01-02 06:24:56 +00:00
Tovin Seven 9986bababd Add kwargs to WsgiMiddleware __init__
Add kwargs to this __init__ method is a way
to avoid some extra keyword arguments in local_conf [1].

    @classmethod
    def factory(cls, global_conf, **local_conf):
        def filter_(app):
            return cls(app, **local_conf)
        return filter_

These extra keyword arguments
can cause this exception (in case of ceilometer):
    `__init__() got an unexpected keyword argument`

[1] https://git.openstack.org/cgit/openstack/osprofiler/tree/osprofiler/web.py#n91

Change-Id: I82e0db75ef9f84075289e360428c09ec68fb72d9
2018-01-02 06:24:28 +00:00
Ilya Shakhat 23e53ec9eb Add functional test for Redis driver
Change-Id: I39d6b8d9f71fd2d0f63873554a6a8ff0075554b8
2017-11-29 14:57:33 +01:00