-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Issue/#477 prometheus #526
Conversation
There are some unit tests failing randomly. I think this is due to some bugs detected by fuzzy tests on the encode csv part. Seems like encode/decode generated an additional "\r" in URL string. I am trying to fix some of them, but I think none is related to Prometheus commit itself. What should we do? |
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.
Thanks for working on this! I'd like us to try to keep the Attacker
separate from Prometheus stuff. The way we can do that is by hooking into the results
channel returned by the Attack
method — for each Result
that we read, we update Prometheus metrics in
Line 203 in d9b795a
case r, ok := <-res: |
docker-compose.yml
Outdated
ports: | ||
- 8880:8880 | ||
environment: | ||
- TARGET_URL=https://www.uol.com.br |
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.
Can we change this default?
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.
Sure. I am changing to www.yahoo.com, is this ok?
|
||
vegeta: | ||
build: . | ||
image: flaviostutz/vegeta |
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.
Would love to build and publish an official project Docker image. I see you opened a separate issue for that. What would it take to get that done?
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.
The Dockerfile/docker-compose.yml created really solves #525. We would close #525 with current PR.
For an official Docker image, you should create a new Repository in Dockerhub with tsenart/vegeta name and we could configure an automated build there that automatically build master "branch" to "latest" and any tagged git to a tagged image in Dockerhub. I have not prepared this Dockerfile thinking about being an official image, because it doesn't support all vegeta properties. We could discuss that in a separate issue if you like.
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.
Another option is we can use a random name in "image" field, because this is only a local name (not necessary published in Dockerhub). What do you think?
- REQUESTS_PER_SECOND=5 | ||
|
||
prometheus: | ||
image: flaviostutz/prometheus |
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.
Same for this image.
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.
This is an extension of the official prometheus image. In this image I added the option to pass scrape configurations using environment variables. In official prometheus image, they place configuration files in volumes, which is not a good pattern because it generates a "stateful" situation on operation (one has to create a configuration file and place in volumes, oposed to simply setting configurations in ENV parameters).
If you like we can remove this service from docker-compose.yml.
var requestSecondsHistogram = promauto.NewHistogramVec(prometheus.HistogramOpts{ | ||
Name: "request_seconds", | ||
Help: "Request latency", | ||
Buckets: []float64{0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20, 50}, |
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.
How have you chosen these buckets?
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.
Based on my experience. Do you have any other references? Surely we can change.
"status", | ||
}) | ||
|
||
var requestBytesInCounter = promauto.NewCounterVec(prometheus.CounterOpts{ |
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.
Because Prometheus can be used as a library, two Attackers
could be instantiated in the same Go process, so global variables for these metrics shouldn't be used.
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.
Sure, but Prometheus lib is thread safe. The two attackers should share the same counters, right? (maybe I missed something)
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.
If summing the two (or more) attackers is not the case, we should differentiate the metrics by a new label...
Co-authored-by: Tomás Senart <[email protected]>
Co-authored-by: Tomás Senart <[email protected]>
By setting a fixed seed to random generators I think those random errors should stop happening so that the tests would be repeatable. What do you think about flyingmutant/rapid#14? |
This comment has been minimized.
This comment has been minimized.
Placing Prometheus outside "Attacker" lib would be great, but we would lose Prometheus support when someone is using the lib. Prometheus would work only from the command line then. The way it was implemented the lib will have Prometheus Exporter too. Placing Prometheus support to the lib should even help the guys from nitishm/vegeta-server#17. What do you think it would be a better pattern? |
You can factor out the Prometheus metrics into a struct type that gets instantiated via a constructors and add a method Observe that takes in a Result. Then it’s easy to use, just create a sub package in lib called prometheus.
Sent via Superhuman iOS ( https://sprh.mn/[email protected] )
…On Sat, Jul 4 2020 at 10:32 PM, Flavio Stutz < ***@***.*** > wrote:
>
>>
>>
>> Thanks for working on this! I'd like us to try to keep the Attacker separate
>> from Prometheus stuff. The way we can do that is by hooking into the results
>> channel returned by the Attack method — for each Result that we read, we
>> update Prometheus metrics in
>> https://github.com/tsenart/vegeta/blob/d9b795aec8585a0fb435072f68d842d596c332de/attack.go#L203
>>
>>
>>
>
>
>
> I will look into that.
>
>
Placing Prometheus outside "Attacker" lib would be great, but we would
lose Prometheus support when someone is using the lib. Prometheus would
work only from the command line then. The way it was implemented the lib
will have Prometheus Exporter too.
Placing Prometheus support to the lib should even help the guys from nitishm/vegeta-server#17
( nitishm/vegeta-server#17 ).
What do you think it would be a better pattern?
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub (
#526 (comment) ) , or unsubscribe
(
https://github.com/notifications/unsubscribe-auth/AAAQPD77RYLOCWCB2HHBODTRZ6GUVANCNFSM4OONPOFQ
).
|
Great! So I will separate concerns but keep Prometheus Exporter capabilities in lib too, right? Thanks. |
Closing this PR to continue review in #534 |
Background
This is a complete initial implementation of Prometheus Exporter support as discussed in #477
Checklist